import type { ResponseData } from '@/utils/types.d';
import { SUCCESS_CODE } from '@/utils/types.d';
import request from '@/utils/request';
import type { RefundRecordItem } from './types.d';

export async function queryRefundRecords(params: any, sort: any) {
  const res: ResponseData<{
    total: number;
    data: RefundRecordItem[];
  }> = await request('/api/refund-record/v1.0.0/refunds', {
    method: 'GET',
    params: {
      data: params,
      sort,
    },
  });
  if (res?.code === SUCCESS_CODE)
    return { success: true, total: res.data.total, data: res.data.data };
  return { success: false, total: 0, data: [] };
}
